# Download zimfw script
local -r ztarget=${ZIM_HOME}/zimfw.zsh
if (
  command mkdir -p ${ZIM_HOME} || return 1
  local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
  if (( ${+commands[curl]} )); then
    command curl -fsSL -o ${ztarget} ${zurl} || return 1
  elif (( ${+commands[wget]} )); then
    command wget -nv -O ${ztarget} ${zurl} || return 1
  else
    print -u2 -P '%F{red}<%= error %>Either %Bcurl%b or %Bwget%b are required to download the Zim script.%f'
    return 1
  fi
); then
  print -PR "<%= okay %>Downloaded the Zim script to %B${ztarget}%b"
else
  command rm -rf ${ZIM_HOME}
  print -u2 -PR "%F{red}<%= error %>Could not download the Zim script to %B${ztarget}%b%f"
  return 1
fi
